export default {
  goodsCount(state) {
    return state.cartList.reduce((total, item) => {
      return item.checked ? total + item.count : total
    }, 0)
  },
  totalPrice(state) {
    let result = state.cartList.reduce((total, item) => {
      return item.checked ? item.price * item.count + total : total
    }, 0)
    return result.toFixed(2)
  },
  allChecked(state) {
    if (state.cartList.length === 0) return false
    return !state.cartList.find(item => item.checked === false)
  }
}
